<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <title>Audio Network - data transmission over sound waves</title>

    <meta name="description" content="">

    <link rel="stylesheet" type="text/css" href="../../asset/css/simple-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../../asset/css/example.css">
    <link rel="stylesheet" type="text/css" href="modulation-types.css">
    <script src="../../asset/js/site.js"></script>
    <meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body onLoad="init()">

    <div id="fb-root"></div>
    <script>
        if (isProduction()) { // TODO refactor this
            (function(d, s, id) {
                var js, fjs = d.getElementsByTagName(s)[0];
                if (d.getElementById(id)) return;
                js = d.createElement(s); js.id = id;
                js.src = "//connect.facebook.net/pl_PL/sdk.js#xfbml=1&version=v2.7&appId=726972757440597";
                fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));
        }
    </script>

    <div class="wrapper">

        <div class="container">
            <h1>Audio Network - send data over sound in JavaScript</h1>
            <div class="row margin-bottom">
                <div class="col col-xs-12">
                    <div class="fb-like-cont">
                        <a href="https://www.facebook.com/Data-transmission-over-sound-500422050157351/" target="_blank" class="a-icon a-icon-fb">
                            <img src="/asset/image/fb.png" alt="Audio Network at Facebook">
                        </a>
                        <div class="fb-like" data-href="https://www.facebook.com/Data-transmission-over-sound-500422050157351/" data-layout="button" data-action="like" data-size="small" data-show-faces="true" data-share="false"></div>
                    </div>
                    <p class="text-right">
                        Return to <a href="https://audio-network.rypula.pl">main page</a>
                    </p>
                    <p class="larger text-center">
                        THIS PROJECT IS STILL UNDER DEVELOPMENT<br/>
                        Source code available at <a href="https://github.com/robertrypula/AudioNetwork" target="_blank">GitHub</a>
                    </p>
                </div>
            </div>

            <!-- ---------------- -->


            <div class="row margin-bottom">
                <div class="col col-xs-12">
                    <p>
                        This example allows to debug few modulation types. Additionally it
                        allows to examine dropped samples and check how those voids looks
                        like in the time domain.
                    </p>
                </div>
            </div>


            <div class="row margin-bottom">
                <div class="col col-xs-12">

                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label for="loopback-checkbox" class="label-compact">
                                Loopback
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="checkbox"
                                onChange="onLoopbackCheckboxChange()"
                                id="loopback-checkbox"
                                value="1" />
                        </div>
                    </div>

                    <div class="row margin-bottom-double" id="audio-mono-io-init-div">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Buffer Size
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <button class="btn btn-default" onClick="onAudioMonoIoInitClick(256)">256</button>
                            <button class="btn btn-default" onClick="onAudioMonoIoInitClick(512)">512</button>
                            <button class="btn btn-default" onClick="onAudioMonoIoInitClick(1024)">1024</button>
                            <button class="btn btn-default" onClick="onAudioMonoIoInitClick(2048)">2048</button>
                            <button class="btn btn-default" onClick="onAudioMonoIoInitClick(4096)">4096</button>
                            <button class="btn btn-default" onClick="onAudioMonoIoInitClick(8192)">8192</button>
                            <button class="btn btn-default" onClick="onAudioMonoIoInitClick(16384)">16384</button>
                        </div>
                    </div>

                    <h2>Recorded buffers</h2>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Record [2 seconds]
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <button class="btn btn-default" onClick="onRecordClick()" id="record-button">
                                Initialize first
                            </button>
                        </div>
                    </div>
                    <div class="margin-bottom-double">
                        <div class="scroll-container">
                            <div id="canvas-container-record" class="clearfix">
                            </div>
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                RAW samples
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <textarea id="raw-samples-record" style="height: 50px;"></textarea>
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                WAV file
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <div id="wav-record"></div>
                        </div>
                    </div>

                    <h2>Test sound</h2>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label class="label-compact">
                                Separation
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="separate-bits-checkbox" />
                                Bits
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="separate-binary-value-checkbox"
                                    checked="checked" />
                                Binary values
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="separate-modulation-types-checkbox"
                                    checked="checked" />
                                Modulation types
                            </div>
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label class="label-compact">
                                Modulation
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-bask-checkbox" />
                                B-ASK (bits of binaryValue encoded as separate B-ASK symbols)
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-ask-checkbox" />
                                ASK (binaryValue encoded as one ASK symbol)
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-bpsk-checkbox" />
                                B-PSK (bits of binaryValue encoded as separate B-PSK symbols)
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-psk-checkbox" />
                                PSK (binaryValue encoded as one PSK symbol)
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-bfsk-checkbox" />
                                B-FSK (bits of binaryValue encoded as separate B-FSK symbols)
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-fsk-checkbox" />
                                FSK (binaryValue encoded as one FSK symbol)
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-chirp-checkbox" />
                                Chirp (bits of binaryValue encoded as separate Chirp symbols)
                            </div>
                            <div class="clearfix">
                                <input
                                    type="checkbox"
                                    id="modulation-ofdm-checkbox"
                                    checked="checked" />
                                OFDM (bits of binaryValue as one OFDM symbol but on separate B-PSK subcarriers)
                            </div>
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Number of binary values
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="number-of-binary-values"
                                value="8" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Number of binary values repetitions
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="number-of-binary-values-repetitions"
                                value="1" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Sample per symbol
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="sample-per-symbol"
                                value="512" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Amplitude - LOW
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="amplitude-low"
                                value="0.1" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Amplitude - HIGH
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="amplitude-high"
                                value="1" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Cycles in symbol duration - LOW
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="cycle-low"
                                value="16" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Cycles in symbol duration - HIGH
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="cycle-high"
                                value="32" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                OFDM pilots
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="text"
                                id="ofdm-frequency-bin-index-pilot"
                                value="23 29" />
                            Frequency bin indexes separated by spaces
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                OFDM data
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="text"
                                id="ofdm-frequency-bin-index-data"
                                value="25 26 27" />
                            This should be equal to number of bits that are needed to store binary value.
                            If you picked 8 as 'Number of binary values' it means that you require 3 bits
                            to store one binary value. In that case you need to provide 3 frequency bin
                            indexes separated by spaces. Please do NOT pick same indexes as at 'OFDM pilots'
                            section.
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                OFDM symbol repetitions
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="ofdm-symbol-repetition"
                                value="2" />
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                OFDM guard (cyclic prefix)
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="number"
                                id="ofdm-guard"
                                value="0.5" />
                            <br/>
                            0 means no cyclic prefix
                            <br/>
                            1 means cyclic prefix duration is equal to symbol duration
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                OFDM guard windowing
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <input
                                type="checkbox"
                                id="ofdm-guard-window"
                                checked="checked" />
                            <br/>
                            When checked part of previous symbol is merged with part of current symbol (0->1, 0->1 cosine window function).
                            No effect when 'OFDM guard' is equal to zero.
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label class="label-compact">
                                Sequence duration
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <span id="sequence-duration"></span>
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                Play
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <button class="btn btn-default" onClick="onPlayClick()" id="play-button">
                                Initialize first
                            </button>
                        </div>
                    </div>
                    <div class="margin-bottom-double">
                        <div class="scroll-container">
                            <div id="canvas-container-play" class="clearfix">
                            </div>
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                RAW samples
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <textarea id="raw-samples-play" style="height: 50px;"></textarea>
                        </div>
                    </div>
                    <div class="row margin-bottom-double">
                        <div class="col col-xs-6 col-sm-5 col-md-3">
                            <label>
                                WAV file
                            </label>
                        </div>
                        <div class="col col-xs-6 col-sm-7 col-md-6">
                            <div id="wav-play"></div>
                        </div>
                    </div>

                </div>
            </div>

            <!-- ---------------- -->

            <script>
                if (isProduction()) { // TODO refactor this
                    document.write('<div class="fb-comments" data-href="' + window.location.href + '" data-numposts="5"></div>');
                }
            </script>

        </div>

        <footer>
            <div class="row">
                <div class="col col-xs-12">
                    <div class="copyright">Robert Rypuła 2015-2018</div>
                </div>
            </div>
        </footer>

    </div>

    <script src="https://cdn.rypula.pl/audio-network/v1.3.2/audio-network-v1.3.2.min.js"></script>

    <script src="../00-00-00-common/ui/convert-util.js"></script>
    <script src="modulation-types.js"></script>

    <script>
        if (isProduction()) { // TODO refactor this
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

            ga('create', 'UA-76662342-1', 'auto');
            ga('send', 'pageview');
        }
    </script>

</body>
</html>
